class Solution:
    def lengthOfLastWord(self, s: str) -> int:
        s = s.strip()
        if s == '': return 0
        return len(s.split()[-1])


if __name__ == '__main__':
    solution = Solution()
    s = ''
    s = 'abc'
    s = 'ab cd e'
    s = 'abc e   '
    s = "Hello World"
    n = solution.lengthOfLastWord(s)
    print(n)